let fs = require('fs')
let zlib = require('zlib')
let path = require('path')
// 用于实现压缩 transform转换流 继承自双工流
function gzip(src){
    fs.createReadStream(src)
        .pipe(zlib.createGzip())
        .pipe(fs.createWriteStream(src + '.gz'))
}

// gzip(path.join(__dirname, 'msg.txt'))

// 解压
function gunzip(src){
    fs.createReadStream(src)
        .pipe(zlib.createGunzip())
        .pipe(fs.createWriteStream(path.join(__dirname, path.basename(src, '.gz'))))
}
gunzip(path.join(__dirname, 'msg.txt.gz'))
